<?php echo $header; ?>

		  <!-- Start - Left Side -->
	      <div id="left" class="span-24">
	      	<div id="product_desc" class="span-24">
	      	<div style="width: 100%;">
	      		<form action="<?php echo str_replace('&', '&amp;', $action); ?>" method="post" enctype="multipart/form-data" id="product">
	      		<div id="product_detail">
	      			
	      			<div id="product_picture"><!-- Start - Product Picture -->
	      			<a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="thickbox" rel="gallery">
		          		<img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" style="border:1px dashed gray; margin-bottom:5px;padding:5px;" />
	          		</a>
	          		<div id="addimg">
	          			<?php if ($images) { ?>
				      <div style="display: inline-block;">
				        <?php foreach ($images as $image) { ?>
				        <div style="display: inline-block; float: left; text-align: center; margin-left: 5px; margin-right: 5px; "><a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="thickbox" rel="gallery"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" style="border: 1px solid #DDDDDD; margin-bottom: 3px;" /></a><br />
				         </div>
				        <?php } ?>
				      </div>
				      <?php } ?>
	          		</div>
	          		</div><!-- End - Product Picture -->
	          		
	          		<div id="product_descriptions"> <!-- Start - Product Description -->
	          		
					<div id="stock">
					<?php if($stock!="In Stock") echo $stock; ?></div>
					
	          		<?php if ($heading_title) { ?>
		             <div id="product_name"><?php echo $heading_title; ?></div>
		            <?php } ?>
		            
		             
		             <div id="product_code"><?php echo $model; ?></div>
		             
		             
	          		<div id="product_price"><?php echo $price; ?></div>

		             <div id="product_option">
		              <?php if ($options) { ?>
		              	 <?php foreach ($options as $option) { ?>
		              <?php echo $option['name']; ?>
		             <span>:&nbsp;&nbsp;&nbsp;</span><select name="option[<?php echo $option['option_id']; ?>]">
				                        <?php foreach ($option['option_value'] as $option_value) { ?>
				                        <option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
				                        <?php if ($option_value['price']) { ?>
				                        <?php echo $option_value['prefix']; ?><?php echo $option_value['price']; ?>
				                        <?php } ?>
				                        </option>
				                        <?php } ?>
				                      </select>&nbsp;&nbsp;&nbsp;
		              <?php } ?>
		              <?php } ?>
		              </div>
		              <?php if($stock=="In Stock") { ?>
					<div id="product_quality"><?php echo $text_qty; ?>&nbsp;&nbsp;&nbsp;<input id="quantity" type="text" name="quantity" size="3" value="<?php echo $minimum; ?>" style="margin-right:10px;" />EA</div>
		              
					<div id="product_button">
						
						
						
		                <a onclick="$('#product').submit();" id="add_to_cart" ><img src="catalog/view/theme/galib/image/cart.png" title="Add to cart" alt="" /></a>
		                <a onclick="$('#product').submit();"  id="check_out_btn"><img src="catalog/view/theme/galib/image/buy.png" title="Add to cart" alt="" /></a>
		                <?php if ($minimum > 1) { ?><br/><small><?php echo $text_minimum; ?></small><?php } ?>
		            </div>
		            <?php } ?>
		              
		              <div>
		                <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
		                <input type="hidden" name="redirect" value="<?php echo str_replace('&', '&amp;', $redirect); ?>" />                
		              </div>
					  
					  
		             </div><!-- End - Product Description -->
		              
	      		</div>
		       </form>
		    </div>
		    
		    <div class="span-24 desc_wrapper">
			    <div class="span-24 desc_header">
			    	&nbsp;
			    </div>
			    <div class="span-24 desc_content">
			    	 <?php echo $description; ?>
			    </div>
		    </div>
		    
		    
		     <div class="span-24 desc_wrapper">
			    <div class="span-24 desc_header">
			    	<div style="margin-top:10px;display:inline-block">
			    	 <?php if ($review_status) { ?><?php echo $tab_review; ?><?php } ?>
			    	 </div>
			    	 <span style="float:right;margin-right:5px;color:purple;cursor:pointer">
			    	 	<a id="review_btn" class="cufon uppercase">Write</a>
		    	 	</span>
			    </div>
			    
			    
			    <div class="span-24 desc_content">
			    	   <?php if ($review_status) { ?>
    <div id="tab_review" class="tab_page">
      <div id="review"></div>
      
      <div id="review_form">
      <div class="heading cufon" id="review_title"><?php echo $text_write; ?></div>
      <div class="content">
      	<TABLE>
      		<TR>
      			<TD width="80%">
      				<TABLE width="100%">
      					<TR>
      						<TD width="20%" style="vertical-align:top;"><b><?php echo $entry_name; ?></b></TD>
      						<TD> <input type="text" name="name" value="" /></TD>
      					</TR>
      					
      					<TR>
      						<TD width="20%" style="vertical-align:top;"><b><?php echo $entry_image; ?></b></TD>
      						<TD>
      							
      							<span id="upload" style="border:1px solid #ddd;background:#eee;display:block;width:100px;height:100px;margin-top:5px;padding:0;">
      								<img src="image/no_image.jpg" alt="" />
      							</span>
      							<input type="hidden" name="review_img" value=""/>
      						</TD>
      					</TR>
      					
      					<TR>
      						<TD width="20%" style="vertical-align:top;"> <b><?php echo $entry_review; ?></b></TD>
      						<TD >  <textarea id="review_description" name="text" style="width: 98%;height:100px !important;" rows="2"></textarea></TD>
      					</TR>
      					<TR>
      						<TD width="20%" style="vertical-align:top;"><b><?php echo $entry_rating; ?></b></TD>
      						<TD >
      							<input type="radio"  id="rating1" name="rating" value="1" style="margin: 0;" />
      							<label for="rating1"><img src="catalog/view/theme/default/image/stars1.png" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" /><lable>
      							 &nbsp;
						        <input type="radio" id="rating2" name="rating" value="2" style="margin: 0;" />
						        <label for="rating2"><img src="catalog/view/theme/default/image/stars2.png" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" /><lable>
						        &nbsp;
						        <input type="radio" id="rating3" name="rating" value="3" style="margin: 0;" />
						       <label for="rating3"> <img src="catalog/view/theme/default/image/stars3.png" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" /><lable>
						        &nbsp;
						        <input type="radio" id="rating4" name="rating" value="4" style="margin: 0;" />
						        <label for="rating4"><img src="catalog/view/theme/default/image/stars4.png" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" /><lable>
						        &nbsp;
						        <input type="radio" id="rating5" name="rating" value="5" style="margin: 0;" />
						        <label for="rating5"><img src="catalog/view/theme/default/image/stars5.png" alt="<?php echo $text_stars; ?>" style="margin-top: 2px;" /><lable>
						     </TD>
      					</TR>
      					<TR>
      						<TD width="20%" style="vertical-align:top;"><b ><?php echo $entry_captcha; ?></b>
      						<TD><input type="text" name="captcha" value="" autocomplete="off" /><br/><br/>
      						 <img src="index.php?route=product/product/captcha" id="captcha" /></TD>
      						</TD>
      					</TR>
      					
      				</TABLE>
      			</TD>
      			<TD style="text-align:center">
      				<div class="galib_btn1 ">
            		<a onclick="review();"><span><?php echo $text_write; ?></span></a>
        </div>
      				
      				
  				</TD>
      		</TR>
      	</TABLE>
      	
      </div>
      </div>
      
      
  </div>
    <?php } ?>
			    </div>	
		    </div>
		    
		    
		   
		    
		    
		  
	      
	        
	      </div>
       	 </div>
	      <!-- End - Left Side -->
       	 
       	


<?php echo $footer; ?> 
<script type="text/javascript"><!--

$('#review_btn').live('click', function() {
	$('#review_form').toggleClass('review_hidden');
	return false;
});			

$('#review .pagination a').live('click', function() {
	$('#review').slideUp('fast');
		
	$('#review').load(this.href);
	
	$('#review').slideDown('fast');
	
	return false;
});			

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

function review() {
	$.ajax({
		type: 'POST',
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&review_img=' + encodeURIComponent($('input[name=\'review_img\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#review_button').attr('disabled', 'disabled');
			$('#review_title').after('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#review_button').attr('disabled', '');
			$('.wait').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review_title').after('<div class="success">' + data.success + '</div>');
				
						
				$('input[name=\'name\']').val('');
				$('input[name=\'review_img\']').val('');
				$('#upload').html('<img src="image/no_image.jpg" alt="" />	');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
}
//--></script>
<script type="text/javascript" src="admin/view/javascript/jquery/ajaxupload.js"></script>
<script type="text/javascript">
$(document).ready(function () { 
		new AjaxUpload('#upload', {
		action: 'index.php?route=common/filemanager/upload',
		name: 'image',
		autoSubmit: true,
		responseType: 'json',
		onChange: function(file, extension) {
			this.submit();
		},
		onSubmit: function(file, extension) {
			$('#upload').append('<img src="admin/view/image/loading.gif" id="loading" style="padding-left: 5px;" />');
		},
		onComplete: function(file, json) {
			if (json.success) {
				$('#upload').html('<img src="'+ json.img +'" alt="" />');
				$("input[type=hidden][name=review_img]").val(json.path);
			}
			
			if (json.error) {
				alert(json.error);
			}
			
			$('#loading').remove();	
		}
	});
});
</script>
<script>
$('.review_list',this).live('click', function() {
	$('.review_content',this).toggleClass('review_hidden');
});	
</script>
